package com.feihao.zhou.demo06PropertiesTest;

import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class PropertiesTest {
    public static void main(String[] args) {
        //创建Properties的对象：
        Properties pro = new Properties();

        //存储元素：
        pro.setProperty("张三","北京");
        pro.setProperty("李四","湖南");
        pro.setProperty("小桑","广东");

        // 获取value:
        String value = pro.getProperty("张三");
        System.out.println("张三："+value);


        //遍历：
        Set<Map.Entry<Object, Object>> entries = pro.entrySet();
        for (Map.Entry<Object, Object> entry : entries) {
            System.out.println(entry.getKey() + "=" + entry.getValue());
        }

        //相当于获取key的集合：
        Set<String> keys = pro.stringPropertyNames();
        for (String key : keys) {
            System.out.println(key +"---->" + pro.getProperty(key));
        }
    }
}
